import { swiperData, waterfallData } from "@/api/worthBuy";

const state = {
	swiperList: [],
	waterfallList: []
};
const mutations = {
	SET_SWIPERLIST(state, swiperList) {
		state.swiperList = swiperList;
	},

	SET_WATERFALLLIST(state, waterfallList) {
		state.waterfallList = waterfallList;
	}
};
const actions = {
	async getSwiperList({ commit }) {
		const result = await swiperData();
		if (result.code == 200) {
			commit("SET_SWIPERLIST", result.data.navList);
			return result.data.navList;
		} else {
			return Promise.reject(new Error("failed"));
		}
	},

	async getWaterfallList({ commit }, { page, size }) {
		const result = await waterfallData(page, size);
		if (result.code == 200) {
			commit("SET_WATERFALLLIST", result.data.result);
			return result.data.result;
		} else {
			return Promise.reject(new Error("failed"));
		}
	}
};
const getters = {};
export default {
	state,
	mutations,
	actions,
	getters
};
